<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>canvas剪辑阴影和曲线</title>
    <style>
        #myCanvas {
            border: 1px solid red;
        }
    </style>
</head>
<body>
<canvas id="myCanvas">
    您的浏览器不支持Canvas，请升级浏览器
</canvas>
<script>
    var canvas = document.getElementById('myCanvas');
    var ctx = canvas.getContext('2d');
    ctx.canvas.width = 600;
    ctx.canvas.height = 400;

//    ctx.save();
    //进行区域编辑
    ctx.arc(300,100,200,0,Math.PI*2,true);
    ctx.clip();

    ctx.fillStyle = "#F00";
    ctx.fillRect(100,100,200,200);

//    ctx.restore();
//    ctx.beginPath();
//    ctx.arc(400,300,100,0,Math.PI*2,true);
//    ctx.fillStyle = "#00F";
//    ctx.fill()

</script>
</body>
</html>